<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1_引出生命周期</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>

    <!-- 准备一个容器 -->
    <div id="root">
        <h1 :style="{opacity: opacity}">Vue 真好玩</h1>
        <br>
    </div>

    <script type="text/javascript">
        new Vue({
            el:'#root',
            data(){
                return{
                    opacity:1
                }
            },
            // 挂载：Vue完成模板的解析并把初始的真实DOM写入页面后，就会调用一次
            mounted() {
                let interval = setInterval(() => {
                    this.opacity -= 0.01
                    if(this.opacity <= 0) {
                        this.opacity += 1
                    }
                }, 15);
                
                console.log('@',interval === 6);
            },
        })
    </script>
</body>

</html>